package cn.wsgfz.test;

import java.util.ArrayList;
import java.util.List;

import cn.wsgfz.testsvgapp.R;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

public class DifficultDataActivity extends BaseActivity {
	private DifficultDataAdapter mDifficAdapter;
	private ListView mListView;
	private ImageView mImageView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.difficult_data_layout);
		mImageView = (ImageView)findViewById(R.id.image_view_01);
		
		// 异步处理
		new AsyncTask<Void, Void, List<DifficultEntity>>() {
			// 后台处理前
			protected void onPreExecute() {
				// 提示消息
				String text  = "数据正在处理,请稍后...";
				int duration = Toast.LENGTH_LONG;
				Toast.makeText(DifficultDataActivity.this, text, duration).show();
			}
			
			// 后台处理中
			protected List<DifficultEntity> doInBackground(Void... params) {
				List<DifficultEntity> list = new ArrayList<DifficultEntity>();
				DifficultHandler handler = new DifficultHandler(DifficultDataActivity.this);
				list.add(handler.getDifficultImageSizeList());
				list.add(handler.getDifficultMemory());
				list.add(handler.getDifficultCpu(mImageView));				
				return list;
			}
			
			// 前台处理(后台已处理完成)
			protected void onPostExecute(List<DifficultEntity> list) {
				mListView = (ListView) findViewById(R.id.data_diffcult_list);
				mDifficAdapter = new DifficultDataAdapter(DifficultDataActivity.this, list, 1);
				mListView.setAdapter(mDifficAdapter);
			}
		}.execute();
		
//		List<DifficultEntity> list = new ArrayList<DifficultEntity>();
//		DifficultHandler handler = new DifficultHandler(DifficultDataActivity.this);
//		list.add(handler.getDifficultImageSizeList());
//		list.add(handler.getDifficultMemory());
//		list.add(handler.getDifficultCpu(mImageView));	
//		
//		mListView = (ListView) findViewById(R.id.data_diffcult_list);
//		mDifficAdapter = new DifficultDataAdapter(DifficultDataActivity.this, list, 1);
//		mListView.setAdapter(mDifficAdapter);
	}
}
